export default /* glsl */ `
varying vec2 uv2;
uniform vec2 ratio;
uniform vec4 gridColor;
uniform vec2 densityAndSlash; // density越大 越稀疏, slash == 1时，为45°倾斜格子

  void main() {
    vec2 pos = uv2 * ratio;
    float density = densityAndSlash.x;
    float slashing = densityAndSlash.y;
    float val0;
    float val1;
    if (slashing == 1.0) {
        val0 = mod(abs(pos.y - pos.x), density);
        val0 = smoothstep(0.1, 0.0, val0);
        
        val1 = mod(abs(pos.y + pos.x), density);
        val1 = smoothstep(0.1, 0.0, val1);
    } else {
        val0 = smoothstep(0.1, 0.0, mod(pos.x, density));
        val1 = smoothstep(0.1, 0.0, mod(pos.y, density));
    }
    vec4 lineColor = max(val0, val1) * gridColor;
    gl_FragColor = lineColor;
  }
    `;
